package problems;

import lib.MathLib;

public class Euler027 extends AbstractEuler {

	@Override
	public Number calculate() {
		int maxConsecutive = 0;
		int maxConsecutive_ProductOfCoefficients = 0;
		
		for (int a = -999; a < 1000; a++) {
			for (int b = -999; b < 1000; b++) {
				int consecutive = 0;
				for (int n = 0; MathLib.isPrime(n*n + a*n + b); n++) {
					consecutive++;
					if (consecutive > maxConsecutive) {
						maxConsecutive = consecutive;
						maxConsecutive_ProductOfCoefficients = a*b;
//							System.out.println("new max of " + maxConsecutive + " for " + a + " and " + b);
					}
				}
			}
		}
		
		return maxConsecutive_ProductOfCoefficients;
	}

	@Override
	protected Number getCorrectAnswer() {
		return -59231;
	}

}
